import axios from 'axios'
import store from '@/store'
const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000
})
// 请求拦截
service.interceptors.request.use(config => {
  const token = store.getters.token
  if (token && !config.noToken) {
    config.headers.Authorization = 'Bearer ' + token
  }
  return config
})
// 响应拦截
service.interceptors.response.use(res => {
  const result = res.data
  return result
// eslint-disable-next-line no-sequences
}), (err) => {
  return Promise.reject(new Error(err.message))
}
export default service
